package com.example.demo.controller;

import com.example.demo.entity.basicdata;
import com.example.demo.entity.deletebasic;
import com.example.demo.mapper.basicdataMapper;
import com.example.demo.service.BasicdataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("basicdata")
@CrossOrigin//允许跨域
@Api(tags= "设备基础信息相关操作类",value = "设备基础信息相关操作类")
public class Basicdata {
    @Resource
    BasicdataService BasicdataService;


    @PostMapping("/insert")
    @ApiOperation(value = "添加设备",notes = "输入所有信息添加设备，成功返回‘添加成功’，失败返回‘添加失败’，设备存在返回‘设备已存在’")
    public String insert(@RequestBody basicdata basicdata)
    {
        return BasicdataService.insert(basicdata);
    }

    @PostMapping("/query")
    @ApiOperation(value = "查询设备",notes = "返回所有设备信息")
    public List query()
    {
        return BasicdataService.query();
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除设备",notes = "根据wfkey和ukey删除设备，成功返回‘删除成功’，失败返回‘删除失败’")
    public String delete(@RequestBody deletebasic deletebasic)
    {
        return BasicdataService.delete(deletebasic);
    }

    @PostMapping("/update")
    @ApiOperation(value = "更新设备信息",notes = "输入所有信息，wfkey和ukey作为标识不能修改")
    public String update(@RequestBody basicdata basicdata)
    {
        return BasicdataService.update(basicdata);
    }
}
